<template>
  <div class="app">
    <!-- 顶部导航栏 -->
    <nav class="navbar">
      <div class="nav-container">
        <div class="nav-logo">
          <img src="/logo-nav.svg" alt="L1n Logo" class="logo-icon" />
          <span class="logo-text">L1n</span>
        </div>
        <div class="nav-links">
          <a href="#" class="nav-link">指南</a>
          <a href="http://localhost:5120" class="nav-link">Vue组件</a>
          <a href="http://localhost:5121" class="nav-link">React组件</a>
        </div>
      </div>
    </nav>

    <!-- Hero 区域 -->
    <section class="hero">
      <div class="hero-container">
        <div class="hero-content">
          <h1 class="hero-title">
            <span class="title-gradient">L1n</span>
          </h1>
          <p class="hero-subtitle">
            Vue & React 组件库
          </p>
          <p class="hero-description">
            快速、现代、易用的组件库解决方案，助力前端开发者构建卓越的 Web 应用
          </p>
          <div class="hero-actions">
            <button class="btn btn-primary" @click="setActiveTab('vue')">
              开始使用
            </button>
            <button class="btn btn-secondary" @click="scrollToFeatures">
              了解更多
            </button>
          </div>
          <div class="hero-stats">
            <div class="stat-item">
              <div class="stat-number">50+</div>
              <div class="stat-label">组件</div>
            </div>
            <div class="stat-item">
              <div class="stat-number">2</div>
              <div class="stat-label">框架</div>
            </div>
            <div class="stat-item">
              <div class="stat-number">100+</div>
              <div class="stat-label">工具函数</div>
            </div>
          </div>
        </div>
        <div class="hero-visual">
          <div class="code-preview">
            <div class="code-content">
              <img src="../public/code-animation.svg" alt="代码演示动画" class="code-animation" />
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 特性展示区域 -->
    <section class="features" ref="featuresSection">
      <div class="features-container">
        <h2 class="section-title">About Us</h2>
        <div class="features-grid">
          <div class="feature-card">
            <div class="feature-icon vue-icon">
              <span>🟢</span>
            </div>
            <h3 class="feature-title">Vue 生态</h3>
            <p class="feature-description">
              基于 Vue 3 构建，完美支持 Composition API 和 TypeScript
            </p>
          </div>
          
          <div class="feature-card">
            <div class="feature-icon react-icon">
              <span>🔵</span>
            </div>
            <h3 class="feature-title">React 生态</h3>
            <p class="feature-description">
              支持 React 18+ 和 Hooks，提供现代化的开发体验
            </p>
          </div>
          
          <div class="feature-card">
            <div class="feature-icon typescript-icon">
              <span>🔷</span>
            </div>
            <h3 class="feature-title">TypeScript</h3>
            <p class="feature-description">
              完整的 TypeScript 支持，提供更好的开发体验和类型安全
            </p>
          </div>
        </div>
      </div>
    </section>

    <!-- 框架选择区域 -->
    <!-- <section class="framework-section">
      <div class="framework-container">
        <h2 class="section-title">选择你的技术栈</h2>
        <div class="framework-tabs">
          <button 
            v-for="tab in tabs" 
            :key="tab.id"
            :class="['framework-tab', { active: activeTab === tab.id }]"
            @click="setActiveTab(tab.id)"
          >
            <span class="tab-icon">{{ tab.icon }}</span>
            <span class="tab-text">{{ tab.name }}</span>
          </button>
        </div>
        
        <div class="framework-content">
          <div v-if="activeTab === 'vue'" class="framework-panel">
            <div class="framework-card">
              <h3>Vue 3 组件库</h3>
              <p>使用 VitePress 构建的现代化 Vue 组件文档</p>
              <div class="framework-actions">
                <button class="btn btn-primary" @click="goToVueDocs">
                  进入 Vue 文档
                </button>
                <button class="btn btn-outline" @click="previewVue">
                  查看示例
                </button>
              </div>
            </div>
          </div>
          
          <div v-if="activeTab === 'react'" class="framework-panel">
            <div class="framework-card">
              <h3>React 18 组件库</h3>
              <p>使用 dumi 构建的现代化 React 组件文档</p>
              <div class="framework-actions">
                <button class="btn btn-primary" @click="goToReactDocs">
                  进入 React 文档
                </button>
                <button class="btn btn-outline" @click="previewReact">
                  查看示例
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section> -->

    <!-- 底部信息 -->
    <footer class="footer">
      <div class="footer-container">
        <p>&copy; 2024 L1n. Made with ❤️</p>
      </div>
    </footer>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

// Tab 数据
const tabs = [
  { id: 'vue', name: 'Vue 文档', icon: '🟢' },
  { id: 'react', name: 'React 文档', icon: '🔵' }
];

// 当前活跃的 Tab
const activeTab = ref('vue');
const featuresSection = ref<HTMLElement>();

// 设置活跃 Tab
const setActiveTab = (tabId: string) => {
  window.location.href = 'http://localhost:5120'
};

// 滚动到特性区域
const scrollToFeatures = () => {
  featuresSection.value?.scrollIntoView({ behavior: 'smooth' });
};


// 预览方法
const previewVue = () => {
  alert('Vue 组件预览功能开发中...');
};

const previewReact = () => {
  alert('React 组件预览功能开发中...');
};
</script>

<style scoped>
* {
  box-sizing: border-box;
}

.app {
  min-height: 100vh;
  background: linear-gradient(180deg, #0d1117 0%, #1a1a2e 50%, #16213e 100%);
  color: #e1e4e8;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 导航栏样式 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(48, 54, 61, 0.48);
  padding: 0 24px;
}

.nav-container {
  max-width: 1152px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo .logo-icon {
  width: 32px;
  height: 32px;
  transition: transform 0.2s;
}

.nav-logo:hover .logo-icon {
  transform: scale(1.05);
}

.nav-logo .logo-text {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(120deg, #bd34fe 30%, #41d1ff);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  gap: 32px;
  align-items: center;
}

.nav-link {
  color: #e1e4e8;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover {
  color: #58a6ff;
}

/* Hero 区域样式 */
.hero {
  padding: 80px 24px 120px;
}

.hero-container {
  max-width: 1152px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
}

.hero-content {
  text-align: left;
}

.hero-title {
  font-size: 64px;
  line-height: 1.1;
  font-weight: 800;
  margin: 0 0 24px 0;
}

.title-gradient {
  background: linear-gradient(120deg, #bd34fe 30%, #41d1ff);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 32px;
  font-weight: 600;
  color: #e1e4e8;
  margin: 0 0 16px 0;
}

.hero-description {
  font-size: 18px;
  line-height: 1.6;
  color: #8b949e;
  margin: 0 0 40px 0;
  max-width: 500px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  margin-bottom: 40px;
}

.hero-stats {
  display: flex;
  gap: 32px;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: #58a6ff;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #8b949e;
}

/* 代码预览样式 */
.hero-visual {
  display: flex;
  justify-content: center;
}

.code-preview {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 480px;
}

.code-header {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 12px 16px;
}

.code-tabs {
  display: flex;
  gap: 8px;
}

.code-tab {
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 6px;
  background: #21262d;
  color: #e1e4e8;
  cursor: pointer;
  transition: background 0.2s;
}

.code-tab.active {
  background: #0969da;
  color: white;
}

.code-content {
  padding: 20px;
}

.code-content pre {
  margin: 0;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 14px;
  line-height: 1.5;
  color: #e1e4e8;
}

/* 按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, #bd34fe 0%, #9333ea 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(189, 52, 254, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(189, 52, 254, 0.4);
}

.btn-secondary {
  background: transparent;
  color: #e1e4e8;
  border: 1px solid #30363d;
}

.btn-secondary:hover {
  background: #21262d;
  border-color: #8b949e;
}

.btn-outline {
  background: transparent;
  color: #58a6ff;
  border: 1px solid #58a6ff;
}

.btn-outline:hover {
  background: #58a6ff;
  color: white;
}

/* 特性展示区域 */
.features {
  padding: 80px 24px;
}

.features-container {
  max-width: 1152px;
  margin: 0 auto;
}

.section-title {
  text-align: center;
  font-size: 48px;
  font-weight: 700;
  margin: 0 0 64px 0;
  background: linear-gradient(120deg, #bd34fe 30%, #41d1ff);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 32px;
}

.feature-card {
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.feature-card:hover {
  background: rgba(22, 27, 34, 0.8);
  border-color: #58a6ff;
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto 20px;
  font-size: 24px;
}

.vue-icon {
  background: rgba(76, 192, 141, 0.1);
  color: #4FC08D;
}

.react-icon {
  background: rgba(97, 218, 251, 0.1);
  color: #61DAFB;
}

.typescript-icon {
  background: rgba(49, 120, 198, 0.1);
  color: #3178C6;
}

.feature-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: #e1e4e8;
}

.feature-description {
  font-size: 16px;
  line-height: 1.6;
  color: #8b949e;
  margin: 0;
}

/* 框架选择区域 */
.framework-section {
  padding: 80px 24px 120px;
}

.framework-container {
  max-width: 800px;
  margin: 0 auto;
}

.framework-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 48px;
  background: #161b22;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #30363d;
}

.framework-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  color: #8b949e;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: transparent;
}

.framework-tab.active {
  background: #0969da;
  color: white;
}

.framework-tab:hover:not(.active) {
  color: #e1e4e8;
  background: #21262d;
}

.framework-content {
  min-height: 200px;
}

.framework-panel {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.framework-card {
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
}

.framework-card h3 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: #e1e4e8;
}

.framework-card p {
  font-size: 16px;
  line-height: 1.6;
  color: #8b949e;
  margin: 0 0 32px 0;
}

.framework-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* 底部样式 */
.footer {
  background: #0d1117;
  border-top: 1px solid #30363d;
  padding: 40px 24px;
  text-align: center;
}

.footer-container {
  max-width: 1152px;
  margin: 0 auto;
}

.footer p {
  margin: 0;
  color: #8b949e;
  font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .hero-container {
    grid-template-columns: 1fr;
    gap: 40px;
    text-align: center;
  }
  
  .hero-title {
    font-size: 48px;
  }
  
  .hero-subtitle {
    font-size: 24px;
  }
  
  .hero-actions {
    justify-content: center;
  }
  
  .nav-links {
    display: none;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
  }
  
  .framework-tabs {
    flex-direction: column;
    align-items: center;
  }
  
  .framework-tab {
    width: 200px;
    justify-content: center;
  }
}
</style>